<?php

	session_start();
	require_once('../config.php');
	include_once("../database/DataBase.php");
	include_once("function.php");

	$cat_name = $_POST["cat_name"];
	$cat_desc = $_POST["cat_desc"];
	$category_id = decrypt_string($_POST["key"]);
	
	$database = New DataBase();
	$database->open_connection();
	$result = $database->updateProductCategory($cat_name, $cat_desc, $_SESSION["company_id"], $category_id);
	
	if(!is_null($result)){
		$database->LogAction($_SESSION["login_id"], "Update", "Update product category : ".$category_id." from ".getIpAddress());
		$_SESSION["message"] = "Update Product category success.";
		header('Location: ../Message.php');
	}
	else{
		echo "fail";
	}
	
	$database->close_connection();
?>
